#include <bits/stdc++.h>
using namespace std;
int n;
int a[100010];
int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a,a+n); multiset<int> st;
    for (int i=0;i<n;i++)
    {
        multiset<int>::iterator it=st.lower_bound(a[i]);
        if (it!=st.begin())
        {
            it--;
            st.erase(it);
        }
        st.insert(a[i]);
    }
    printf("%d\n",(int)st.size()); return 0;
}